﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using System.Linq.Expressions;

namespace Mall.Infrastructure.Repository
{
    public interface IRepository<TEntity> where TEntity : class
    {
        void Add(TEntity entity);
        //查询
        IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> spec);

        IQueryable<TEntity> Where(Expression<Func<TEntity, int, bool>> predicate);

        //移除model
        void Remove(TEntity entity);
        //更新model
        void Update(TEntity entity);
        //批量删除
        int Delete(Expression<Func<TEntity, bool>> predicate);
        //批量更新
        int Update(Expression<Func<TEntity, TEntity>> updater, Expression<Func<TEntity, bool>> where);
        //获取上下文
        object GetContext();
    }
}
